<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    
    <title>解约外部合约车</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	<link rel="stylesheet" type="text/css" href="styles.css">

	<link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css">
	<script type="text/javascript" src="../../js/jquery-3.1.0.min.js" charset="UTF-8"></script>
  </head>
  
  <body>
    <div>
    	<label>原合同编号：</label>
		&nbsp;&nbsp;&nbsp;
		<input type="text" name="cbdNo" id="cbdNo" placeholder="原合同编号">		&nbsp;&nbsp;
		<input class="btn btn-primary" type="button" value="查询" onclick="search()">

		<br>
		<div id="tablediv">
			<table style="margin:0px;" class="table table-striped table-bordered table-condensed">
			<thead>
				<tr>
					<th style="width:279px;">合同编号</th>
					<th style="width:89px;">合同单位</th>
					<th style="width:249px;">对方联系人</th>
					<th style="width:109px;">对方联系电话</th>
					<th>车位所在单位详细地址</th>
					<th>车位编号</th>
				</tr>
			</thead>
			</table>
			<div id="table_bottomDiv" style="overflow-y: scroll;height:400px;">
			<table  class="table table-striped table-bordered table-condensed">
			<tbody id="tableContent">
			
			</tbody>
			</table>
			</div>
		</div>
		<input type="hidden" id="cbdpactNo"/>
    	<input style="margin-top:-10px;" type="button" class="btn btn-info" value="解约" onclick="cancle()">
    
    </div>
  </body>
  <script type="text/javascript">
  function search(){
		var pactNo = $("#cbdNo").val();
		$.ajax({
			type:"post",
			url:"findAllCompanyPactByPactNo.do",
			data:{"cbdNo":pactNo},
			async:false,
			success:function(msg){
				var table="";
				$.each(msg,function(i,n){
					var carportNo="";
					$.each(n.companycarport,function(j,k){
						carportNo +=k.carportNO+",";
					})
					table+="<tr onclick='chooseCbdPact("+n.pactID+")'><td style='width:279px;'>"+n.pactNO+"</td><td style='width:89px;'>"+n.comp.companyName+"</td><td style='width:249px;'>"+n.comp.companyBoss+"</td><td style='width:109px;'>"+n.comp.companyTel+"</td><td style='width:254px;'>"+n.comp.companyAddress+"</td><td>"+carportNo+"</td></tr>";
				})
				$("#tableContent").empty();
				$("#tableContent").append(table);
				
			}
		})
	}
  function chooseCbdPact(id){
	  $("#cbdpactNo").val(id);
  }
  function cancle(){
	  var id =$("#cbdpactNo").val();
	  if(id==""){
		  alert("请选择具体合约");
	  }else{
		  $.ajax({
			  type:"post",
			  url:"cancleCompPact.do",
			  data:{"id":id},
			  success:function(msg){
				  if(msg=="success"){
					  alert("解约成功");
					  window.location.href="welcome.jsp";
				  }else{
					  alert("解约失败");
				  }
			  }
		  })
	  }
		 
  }
  </script>
</html>
